- Write a C++ program that does the following:
- It declares two integer variables x, y.
- Prompts the user to enter two integer values and reads them into x and y and then prints the following:
- the sum of x and y
- y subtracted from x
- the product of x and y
- the average of x and y
- the remainder when x is divided by y
Sample run of program:
Enter a value for x: 5
Enter a value for y: 4
The sum of 5 and 4 is 9
4 subtracted from 5 is 1
The product of 5 and 4 is 20
The average of 5 and 4 is 4.5
The remainder when 5 is divided by 4 is 1
- Write a program that computes and prints the area and perimeter of a letter-size (8.5 x 11 inches) sheet of paper. Please do not work with numbers; work with variables.
- The formula for area is base times height
- The formula for perimeter is 2 times base + 2 times height
Sample run of program:
The area of letter-size sheet of paper is 93.5
The perimeter of a letter-size sheet of paper is 39
- Write a C++ program that prompts a user to enter a four-digit integer and prints the number in reverse. HINT: Print one digit at a time, starting from the right of the number.
Sample run of program:
Enter a four-digit number: 3412
Your number in reverse is 2143
- Ask the user to enter his/her name and his/her height in inches. Store the name in a string variable and the height in an int variable. Convert the height to centimeters.
- To convert inches to centimeters, multiply by 2.54
Sample run of program:
Enter your name: Dave
Enter your height in inches: 61
Hi Dave. You are 154.94 centimeters tall.
- Write a program that computes the total score for a basketball game. Prompt the user for the number of 3-pointers scored and 2-pointers scored and find the final points for the team. Print that total to the monitor.
Sample run of program:
How many 3-pointers?
> 10
How many 2-pointers?
7
Total points scored: 44